package StringStudy;

import java.util.Random;
import java.util.Scanner;


public class StringLearn5 {
    //输入一个字符串
    //打乱顺序
    public static void a() {
        char r;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入字符串");
        Random random = new Random();
        String str = scanner.next();
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            int rd = random.nextInt(chars.length);
            //调换位置 r是中间值
            r = chars[i];
            chars[i] = chars[rd];
            chars[rd] = r;
        }
        String s = new String(chars);
        System.out.println("s = " + s);
    }

//    需求: 从键盘输入一个长度小于等于9的数字字符串，将内容变成罗马数字，
//            *     注意：罗马数字没有0，如果键盘录入0，可以变成""
//            *
//            *     同时对用户输入数字字符串的合法性进行检查判断

    public static void b() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入数字字符串");
        String szc = scanner.next();
        for (int i = 0; i < szc.length(); i++) {
            if ('0' <= szc.charAt(i) && szc.charAt(i) <= '9') {

            } else {
                System.out.println("非法字符，请输入数字字符串");
                Scanner scanner1 = new Scanner(System.in);
                szc = scanner1.next();
            }
        }
        String[] arr = {"", "Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ（IIII）", "Ⅴ", "Ⅵ", "Ⅶ", "Ⅷ", "Ⅸ", "Ⅹ", "Ⅺ", "Ⅻ"};
        String res = "";
        for (int i = 0; i < szc.length(); i++) {
            res += arr[szc.charAt(i) - '0'];
        }
        System.out.println("res = " + res);

    }

    public static void main(String[] args) {
        b();
    }
}
